wallLookup = 
    0 : [64, 432]
    1 : [64, 448]
    2 : [48, 432]
    3 : [64, 496]
    4 : [64, 416]
    5 : [80, 480]
    6 : [64, 464]
    7 : [64, 480]
    8 : [80, 432]
    9 : [112, 496]
    10 : [80, 464]
    11 : [96, 496]
    12 : [112, 464]
    13 : [112, 480]
    14 : [96, 464]
    15 : [96, 480]


class window.Tile
    constructor : (@g, @x, @y, @t) ->
        @tileSpr = [0, 496]
        @hasWall = false

    wallType : ->
        type = 0
        type |= 1 if @t.getTile(@x, @y - 1)?.isWall()
        type |= 2 if @t.getTile(@x + 1, @y)?.isWall()
        type |= 4 if @t.getTile(@x, @y + 1)?.isWall()
        type |= 8 if @t.getTile(@x - 1, @y)?.isWall()
        return type


    getWallSprite : ->
        type = @wallType()
        k = wallLookup[type]
        return k

    createTile : (fn, fw) ->
        fn @x, @y, @tileSpr[0], @tileSpr[1]

        return if not @isWall()
        sprWall = @getWallSprite()
        fw @x, @y, sprWall[0], sprWall[1]

    isWall : () ->
        return @hasWall

    solid : () ->
        return @hasWall

    standingOn : (e) ->
        
    touched : (e) ->